/**
 * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
 *
 * 
 * @param number long长整型 
 * @return long长整型
 */
 function cutRope( number ) {
  // write code here
  //发现:能凑3就凑3，实在不行就凑2，但是千万不能凑出来1
  
  //先决情况
  if(number===2){return 1};
  if(number===3){return 2};
  if(number===4){return 4};
  const cnt = Math.floor(number/3);
  if(number%3 === 0){
      return Number(getPowRes(cnt));
  }
  if(number%3 === 1){
      return (4*Number(getPowRes(cnt-1))) % 998244353;
  }
  if(number%3 === 2){
      return (2*Number(getPowRes(cnt))) % 998244353;
  }

}
//快速幂运算:3的cnt次幂
  function getPowRes(cnt){
      if(cnt === 0){return 1};
//         let part = Math.pow(3,cnt/2)
//         if(cnt%2 == 0){
//             return part*part%998244353;
//         }
//         return 3*part*part%998244353;
      const cntRemainder2 = cnt % 2, halfCnt = Math.floor(cnt / 2);
      const partCnt = BigInt(getPowRes(halfCnt));
      if (cntRemainder2 === 0) {
          return BigInt((partCnt * partCnt)) % 998244353n;
       }
          return 3n * BigInt((partCnt * partCnt)) % 998244353n;
      }
module.exports = {
  cutRope : cutRope
};